<template>
  <div class="nav">
    <div class="banxin">
      <img class="logo" src="../assets/images/indexLogo.png" alt="">
      <ul>
        <li @click="$router.push('/home')" :class="$route.path === '/home'?'active':''">首页</li>
        <li @click="$router.push('/goods')" :class="$route.path === '/goods'?'active':''">全部商品</li>
        <li @click="$router.push('/user')" :class="$route.path === '/user'?'active':''">个人中心</li>
        <li @click="$router.push('/dingdan')" :class="$route.path === '/dingdan'?'active':''">我的订单</li>
        <li @click="$router.push('/free')" :class="$route.path === '/free'?'active':''">专属福利</li>
      </ul>
      <div class="search">
      <input @keydown.13="searchGoodsFn" v-model.trim="searchData" type="text" placeholder="搜索全部商品直接回车">
      
      <span @click="searchGoodsFn">
        <img src="../assets/images/search.png" alt="">
      </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
data(){
  return{
    searchData:''
  }
},
methods:{
  searchGoodsFn(){
    this.$router.push(`/goods?keyword=${this.searchData}`)
    this.searchData=''
 }
}
}
</script>

<style lang="less" scoped>
@import "../totao.css";
.nav{
  .banxin{
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 118px;
    // .logo{
    //   height: 68px;
    // }
    ul{
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 500px;
      cursor: pointer;
      li{
        font-size: 16px;
        color: #242b39;
        font-weight: 500;
        &.active{
          font-weight: bold;
          color: #0a328e;
        }
      }
    }
    .search{
     
      width: 264px;
      height: 40px;
      display: flex;
      align-items: center;
      input{
        width: 214px;
        height: 40px;
        border: 1px solid #dedede;
        border-radius: 20px 0 0 20px;
        padding: 0;
        outline: none;
        box-sizing: border-box;
        //防止光标溢出
        text-indent: 1em;
      } 
      span{
        cursor: pointer;
        width: 50px;
        height: 40px;
        background: #0a328e;
        border-radius: 0px 20px 20px 0px;
        text-align: center;
        line-height: 40px;
      }
    }
  }
}
</style>

